﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using AutumnEngine.Modules;
using System.IO;


namespace AutumnEngine.Modules
{
    public class GamepadInputModule : Module
    {

        List<GamePadState> current, last;
        public override void Create()
        {
            current = new List<GamePadState>();
            last = new List<GamePadState>();
            for (int i = 1; i <= 4; i++)
            {
                current.Add(GamePad.GetState(IntToIndex(i)));
                last.Add(GamePad.GetState(IntToIndex(i)));
            }
            base.Create();
        }

        public override void Update()
        {
            for (int i = 1; i <= 4; i++)
            {
                last[i] = current[i];
                current[i] = GamePad.GetState(IntToIndex(i));
            }
            base.Update();
        }

        protected PlayerIndex IntToIndex(int val)
        {
            switch (val)
            {
                case 1:
                    return PlayerIndex.One;
                case 2:
                    return PlayerIndex.Two;
                case 3:
                    return PlayerIndex.Three;
                case 4:
                    return PlayerIndex.Four;
                default:
                    return PlayerIndex.One;
            }
        }

        //Todo isButtonDown etc
    }
}
